//
//  PaymentTableViewCell.swift
//  Pods
//
//  Created by eme on 2017/3/23.
//
//

import UIKit
import RickonCore
import BrandonCore

class PaymentTableViewCell: UITableViewCell {
    
    @IBOutlet weak var pj_btn: UIButton!              //评价按钮
    @IBOutlet weak var dfh_btn: UIButton!             //待发货按钮
    @IBOutlet weak var dsh_btn: UIButton!             //待收货按钮
    @IBOutlet weak var dfk_Btn: UIButton!             //待发货按钮
    @IBOutlet weak var FK_MessageCountLaebl: UILabel! //待付款订单数量
    @IBOutlet weak var FH_MessageCountLabel: UILabel! //待发货订单数量
    @IBOutlet weak var SH_MessageLabel: UILabel!      //待收货订单数量
    @IBOutlet weak var PJ_MessageLabel: UILabel!      //待评价订单数量
    
    
    var item:OrderNumModel!{
        didSet{
            if let model = item{
                if case .audited = AppData.appState {
                    if model.dfk_Num == ""{
                        self.FK_MessageCountLaebl.isHidden = true
                    }else{
                        self.FK_MessageCountLaebl.isHidden = false
                        radiusWithLabel(label: FK_MessageCountLaebl)
                        self.FK_MessageCountLaebl.text = model.dfk_Num
                    }
                    if model.fh_Num == ""{
                        self.FH_MessageCountLabel.isHidden = true
                    }else{
                        self.FH_MessageCountLabel.isHidden = false
                        radiusWithLabel(label: FH_MessageCountLabel)
                        self.FH_MessageCountLabel.text = model.fh_Num
                    }
                    if model.sh_Num == ""{
                        self.SH_MessageLabel.isHidden = true
                    }else{
                        self.SH_MessageLabel.isHidden = false
                        radiusWithLabel(label: SH_MessageLabel)
                        self.SH_MessageLabel.text = model.sh_Num
                    }
                    if model.pj_Num == ""{
                        
                        self.PJ_MessageLabel.isHidden = true
                        
                    }else{
                        self.PJ_MessageLabel.isHidden = false
                        radiusWithLabel(label: PJ_MessageLabel)
                        self.PJ_MessageLabel.text = model.pj_Num
                    }
                }else{
                    self.FK_MessageCountLaebl.isHidden = true
                    self.FH_MessageCountLabel.isHidden = true
                    self.SH_MessageLabel.isHidden = true
                    self.PJ_MessageLabel.isHidden = true
                }
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        self.dfk_Btn.changeEdgeVertical(11)
        self.dfh_btn.changeEdgeVertical(11)
        self.dsh_btn.changeEdgeVertical(11)
        self.pj_btn.changeEdgeVertical(11)
        
        for btn in [dfk_Btn,dfh_btn,dsh_btn,pj_btn]{
            
            setFontForBtn(label: (btn?.titleLabel!)!, size: 12)
        }
        for label in [FK_MessageCountLaebl,FH_MessageCountLabel,SH_MessageLabel,PJ_MessageLabel]{
            setFontForBtn(label: label!, size: 9)
        }
        
        
        
    }
    func setFontForBtn(label:UILabel,size:CGFloat){
        label.normal_fontSize(size)
    }
    func radiusWithLabel(label:UILabel){
        
        label.backgroundColor = UIColor.white
        label.layer.masksToBounds = true
        label.layer.cornerRadius = 8
        label.layer.borderColor = Theme.sansa.order.orderNumBorderColor.cgColor
        label.layer.borderWidth = 1
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }

}
